package ru.papergames.battleserver.network.serverpackets.flashuser;

import ru.common.util.Point3D;
import ru.papergames.battleserver.model.battle.BattlePlayer;
import ru.papergames.battleserver.model.battle.GameBall;

import java.util.Collections;
import java.util.List;

/**
 * @author Alexander Troshanin
 */
public class BattlePlayerMovedBall extends PaperGameServerPacket {

    private BattlePlayer player;
    private List<Point3D> route;
    private GameBall gameBall;

    public BattlePlayerMovedBall(BattlePlayer player, List<Point3D> route, GameBall gameBall) {
        this.player = player;
        this.route = route;
        this.gameBall = gameBall;
    }

    public List<Point3D> getRoute() {
        return Collections.unmodifiableList(route);
    }

    @Override
    protected int getPacketId() {
        return BATTLE_PLAYER_MOVED_BALL_PACKET_ID;
    }

    @Override
    protected void writePacketData() {
        // TODO: action time
        writeD(player.getBattle().getBattleOrderId());
        writeQ(player.getId());
        writeH(gameBall.getColor().getId());
        writeH(route.size());
        for (Point3D point : route) {
            writeH(point.getX());
            writeH(point.getY());
        }
    }

}
